package com.bwda.dsrs.filecenter.service.impl;

import com.bwda.dsrs.filecenter.domain.po.executionhistory.ExecutionHistoryPo;
import com.bwda.dsrs.filecenter.domain.condition.executionhistory.ExecutionHistoryCondition;
import com.bwda.dsrs.filecenter.mapper.dsrs.ExecutionHistoryMapper;
import com.bwda.dsrs.filecenter.service.ExecutionHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@Service
public class ExecutionHistoryServiceImpl extends BaseServiceImpl<ExecutionHistoryPo, ExecutionHistoryCondition, ExecutionHistoryMapper> implements ExecutionHistoryService {
    @Resource
    private ExecutionHistoryMapper executionHistoryMapper;
    @Override
    public int queryRuningTaskCountByTaskIds(Long[] taskIds) {
        return executionHistoryMapper.queryRuningTaskCountByTaskIds(taskIds);
    }

    @Override
    public void deleteByIds(Long[] auditHistoryIds) {
        executionHistoryMapper.deleteByIds(auditHistoryIds);
    }

    @Override
    public List<ExecutionHistoryPo> queryResAuditTaskHistoryById(Long[] auditHistoryIds) {
        return executionHistoryMapper.queryResAuditTaskHistoryById(auditHistoryIds);
    }

    @Override
    public void updateTaskHistoryProcess(Long auditHistoryId, Long speedProcess, Long exeDuration) {
        if (auditHistoryId == null || speedProcess == null) {
            return;
        }
        Map<String, Object> param = new HashMap<>();
        param.put("auditHistoryId",auditHistoryId);
        param.put("speedProcess",speedProcess);
        param.put("exeDuration",exeDuration);

        this.getMapper().updateProcess(param);
    }
}